<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <button onclick="runFunc()"> click </button>
  <button onclick="addFunc()"> add </button>
  <script>
    // const generatordemo = function (data) {
    //   let data = data;
    //   let i = 0;
    //   function next() {
    //     (data && data.length >= i) {
    //       i++;
    //       console.log(" data = ", data)
    //       return data[i]
    //     }
    //   }

    //   [Symbol.iterator]() {
    //     return this;
    //   },
    // }

    // const p = generatordemo([1, 2, 3, 4, 5])
    const arr = new Map(new Array( ["a", "b", "c"]));
    // const arr = ["a", "b", "c"];

    function* gen() {
      yield* arr
    }
    const gen1 = gen();
    function runFunc() {
      console.log(gen1.next().value)
      console.log(arr)
    }
    function addFunc() {
      arr.push(1123)
    }
  </script>
</body>

</html>